#pragma once

#include <cstdio>

// Logging class.
// Don't create multiple instances.
class Logger
{
public:
	// Error types. CRITICAL terminates the application.
	enum	Error_type {NORMAL, CRITICAL};

	// Opens a logfile with a specified filename.
	// If a file already exists, it is truncated.
	explicit Logger(const char* Filename);

	// Closes the logfile.
	virtual	~Logger();

	// Logs an usual message.
	void	Msg(const char* Message);

	// Logs an error message.
	// If Type is set to Error_type::CRITICAL, the application is terminated.
	void	Error(const char* Message, Logger::Error_type Type = NORMAL);

	// Enables or disables logging.
	void	Enable();
	void	Disable();

private:
	char	filename[256];
	FILE*	file;
	bool	logging;
};

extern Logger* log;